package app.services.impl;

import java.io.Serializable;
import java.util.List;

import app.repositories.Repository;
import app.services.GenericService;

public abstract class GenericServiceImpl<T, ID extends Serializable> implements GenericService<T, ID> {

    protected Repository<T, ID> genericRepository;
    
    public T find(ID id) {
        return this.getGenericRepository().find(id);
    }

    public void create(T entity) {
        this.getGenericRepository().create(entity);
    }

    public void update(T entity) {
        this.getGenericRepository().update(entity);
    }

    public void delete(T entity) {
        this.getGenericRepository().delete(entity);
    }

	public List<T> findAll() {
		return this.getGenericRepository().findAll();
	}

	protected Repository<T, ID> getGenericRepository() {
		return genericRepository;
	}

	protected void setGenericRepository(Repository<T, ID> genericRepository){
		this.genericRepository = genericRepository;
	}
    
}